import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int []ve = new int [n];
        int e0 = 0,e0hasOne = 0;
        for(int i = 0;i < n;i ++){
            ve[i] = sc.nextInt();
            e0 ^= ve[i];
        }///e0的值肯定为那两个出现奇数次的数
        int oneInK = e0 &(~e0 + 1);///找到第K位为1的位置
        for(int i = 0;i < n;i ++){
            if( (oneInK & ve[i]) != 0){///与数组中只有第K位上是1的整数异或
                e0hasOne ^= ve[i];
            }
        }
        int a,b;
        if(e0hasOne > (e0 ^ e0hasOne)){
            b = e0hasOne;
            a = (e0 ^ e0hasOne);
        }else{
            b = (e0 ^ e0hasOne);
            a = e0hasOne;
        }
        System.out.println(a + " " + b);
    }
}